<template>
<h1>计算器练习</h1>
  <input type="text" placeholder="请输入数字1" v-model="a">
  <input type="text" placeholder="请输入数字2" v-model="b">
  <button @click="calc('+')">加</button>
  <button @click="calc('-')">减</button>
  <button @click="calc('*')">乘</button>
  <button @click="calc('/')">除</button>
  <h4>结果为:{{c}}</h4>
</template>

<script setup>
import {ref} from "vue";

const a=ref('');
const b=ref('');
const c=ref('');
const calc=(o)=>{
  c.value=eval(a.value+o+b.value);
}
</script>

<style scoped>

</style>